package com.resource.loginlogoutmanange.controller;

import com.resource.common.utils.AppResponse;
import com.resource.loginlogoutmanange.dto.LoginDTO;
import com.resource.loginlogoutmanange.service.TLoginInformationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;


@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private TLoginInformationService tLoginInformationService;

    @PostMapping("register")
    public AppResponse register(@RequestBody LoginDTO loginDTO, HttpSession httpSession){
        return tLoginInformationService.register(loginDTO,httpSession);
    }

    //登录接口
    @PostMapping("login")
    public AppResponse login(@RequestBody LoginDTO loginDTO, HttpSession httpSession){
       return tLoginInformationService.login(loginDTO, httpSession);
    }

    @GetMapping("logout")
    public AppResponse logout(@RequestParam("token") String token){
        return tLoginInformationService.logout(token);
    }

}
